package com.ttn.student.controller;

import com.ttn.common.core.entity.Result;
import com.ttn.common.core.entity.studentrecord.query.LearningProgressQuery;
import com.ttn.common.core.entity.studentrecord.query.UnitReportQuery;
import com.ttn.student.service.LearningProgressRecordService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * (learning_progress_record)表控制层
 *
 * @author xxxxx
 */
@RestController
@RequestMapping("/learning-progress-record")
@Slf4j
public class LearningProgressRecordController {
    /**
     * 服务对象
     */
    @Resource
    private LearningProgressRecordService learningProgressRecordService;

    /**
     * 通过学员id,查询学员学习地图
     *
     * @param learningProgressQuery
     * @return
     */
    @PostMapping("/query/learning-progress")
    public Result queryLearningProgress(@RequestBody LearningProgressQuery learningProgressQuery) {
        log.info("LearningProgressRecordController queryLearningProgress ,参数:{}", learningProgressQuery);
        return learningProgressRecordService.queryLearningProgress(learningProgressQuery);
    }

    /**
     * 通过id,获取首页信息
     *
     * @param studentId
     * @return
     */
    @PostMapping("/query/home-information-by-studentId/{studentId}")
    public Result queryHomeInformation(@PathVariable Integer studentId, HttpServletRequest request) {
        log.info("LearningProgressRecordController queryHomeInformation ,参数:{}", studentId);
        return learningProgressRecordService.queryHomeInformation(studentId, request);
    }

    /**
     * 查询单元详情
     *
     * @param unitId
     * @param studentId
     * @return
     */

    @PostMapping("/query/learning-progress-unit-id/{unitId}/{studentId}")
    public Result queryLearningProgressByUnitId(@PathVariable("unitId") Integer unitId, @PathVariable("studentId") Integer studentId) {
        log.info("LearningProgressRecordController queryLearningProgressByUnitId ,参数:unitId:{},studentId:{}", unitId, studentId);
        return learningProgressRecordService.queryLearningProgressByUnitId(unitId, studentId);
    }

    /**
     * 查询单元报告数据
     *
     * @param unitReportQuery
     * @return
     */
    @PostMapping("/query/unit-report")
    public Result queryUnitReport(@RequestBody UnitReportQuery unitReportQuery) {
        log.info("LearningProgressRecordController queryUnitReport ,参数:unitReportQuery:{}", unitReportQuery);
        return learningProgressRecordService.queryUnitReport(unitReportQuery);
    }

}
